local M = {}

-- 获取通用配置
M.get_common_config = function(on_attach, capabilities)
  return {
    on_attach = on_attach,
    capabilities = capabilities,
  }
end

-- 语言服务器配置加载器
M.load_config = function(server_name, on_attach, capabilities)
  local ok, server_config = pcall(require, "lsp.servers." .. server_name)
  if ok then
    return vim.tbl_deep_extend(
      "force",
      M.get_common_config(on_attach, capabilities),
      server_config
    )
  end
  return M.get_common_config(on_attach, capabilities)
end

-- 需要确保安装的语言服务器
M.ensure_installed = {
  "lua_ls",
  "pyright",
  "clangd",
  "jdtls",
  "ts_ls",  -- 替换 tsserver
  "jsonls",
  "yamlls",
  "bashls",
  "gopls",
  "kotlin_language_server",
  "volar",
  "html",
  "perlnavigator",
  "rust_analyzer",
  "cssls",
  "docker_compose_language_service",
  "dockerls",
  "eslint",
  "graphql",
  "marksman",
}

-- 需要自动配置的语言服务器
M.servers = {
  "clangd",
  "pyright",
  "jdtls",
  "ts_ls",  -- 替换 tsserver
  "jsonls", 
  "yamlls",
  "bashls",
  "gopls",
  "volar",
  "html",
  "perlnavigator",
  "rust_analyzer",
  "cssls",
  "docker_compose_language_service",
  "dockerls",
  "eslint",
  "graphql",
  "marksman",
}

return M
